package com.aidong.myprofile.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aidong.activity.entity.Member;
import com.aidong.login.dao.MemberInformationDao;
import com.aidong.myprofile.biz.TrnAttentionBiz;
import com.aidong.myprofile.dao.TrnAttentionDao;
import com.aidong.myprofile.entity.TrnAttention;

@Service("trnAttentionBiz")
public class TrnAttentionBizImpl implements TrnAttentionBiz {
	
	private TrnAttentionDao attentionDao;
	
	private MemberInformationDao memberInformationDao;

	@Autowired
	public void setAttentionDao(TrnAttentionDao attentionDao) {
		this.attentionDao = attentionDao;
	}

	@Autowired
	public void setMemberInformationDao(MemberInformationDao memberInformationDao) {
		this.memberInformationDao = memberInformationDao;
	}

	/**
	 * 加关注
	 * @param attention
	 */
	@Override
	public void addTrnAttention(TrnAttention attention) {
		attentionDao.addTrnAttention(attention);
		// 增加热度值
		Map<String, Object> paraMap = new HashMap<String, Object>();
		paraMap.put("idongId", attention.getAttentionIdongId());
		memberInformationDao.addMemberPopty(paraMap);
	}

	/**
	 * 取消关注
	 * @param attention
	 */
	@Override
	public void delTrnAttention(TrnAttention attention) {
		attentionDao.delTrnAttention(attention);
		// 减去热度值
		Map<String, Object> paraMap = new HashMap<String, Object>();
		paraMap.put("idongId", attention.getAttentionIdongId());
		memberInformationDao.delMemberPopty(paraMap);
	}

	/**
	 * 关注列表
	 * @param focusId
	 * @return
	 */
	@Override
	public List<Member> getFocusList(Map<String, Object> map) {
		return attentionDao.getFocusList(map);
	}

	/**
	 * 粉丝列表
	 * @param fansId
	 * @return
	 */
	@Override
	public List<Member> getFansList(Map<String, Object> map) {
		List<Member> members = attentionDao.getFansList(map);
		return members;
	}

	/**
	 * 关注状态
	 * @param attention
	 * @return
	 */
	@Override
	public String getIfAttentionStatus(TrnAttention attention) {
		return attentionDao.getIfAttentionStatus(attention);
	}

}
